package com.shuoyue.ycgk.views.dialog.pricedialog;

import android.text.Html;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.entity.course_teacher.AppPrice;

import java.util.List;

/**
 * 倍速适配器
 */
public class PriceAdapter extends BaseQuickAdapter<AppPrice, BaseViewHolder> {

    public PriceAdapter(List data) {
        super(R.layout.item_price, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, AppPrice item) {
        helper.addOnClickListener(R.id.lay_all);
        helper.setText(R.id.price, "￥" + item.getPrice());
        helper.setGone(R.id.lay_price_vip, !TextUtils.isEmpty(item.getVipPrice()));
        helper.setText(R.id.vip_price, "￥" + item.getVipPrice());
        helper.setText(R.id.days, Html.fromHtml(
                "有效期"
                        + (item.getEffectiveTime() == 0 ?
                        "<font color='#06A0DC'>永久</font>"
                        : "<font color='#06A0DC'>" + item.getEffectiveTime() + "</font>天")
        ));
        //item.getEffectiveTime() == 0 ? "永久" :
        //                ("有效期:" + item.getEffectiveTime() + "天")
// tvRight.setText(Html.fromHtml("<font color='#FFFFFF'>已有账号？直接绑定</font>"));
        helper.setBackgroundRes(R.id.lay_all, item.isSelect()
                ? R.drawable.bg_corner4_blue_stroc1
                : R.drawable.bg_corner4_gray_stroc1);
    }


    public AppPrice getSelect() {
        for (AppPrice appPrice : mData) {
            if (appPrice.isSelect()) {
                return appPrice;
            }
        }
        return null;
    }
}